package com.closer.server.api.admin;

import com.closer.server.biz.user.dto.AddRequest;
import com.closer.server.biz.user.dto.UpdateByAdminRequest;
import com.closer.server.biz.user.service.UserService;
import com.closer.server.support.common.BaseResponse;

import com.closer.server.support.common.ResultUtils;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/admin/user")
public class AdminUserController {

    private final UserService userService;
    public AdminUserController(UserService userService) {
        this.userService = userService;
    }


    @PostMapping("/delete")
    public BaseResponse<Boolean> delete(@RequestParam Long id){
        var result = userService.delete(id);
        return ResultUtils.success(result);
    }

    @PostMapping("/update")
    public BaseResponse<Boolean> update(@RequestBody UpdateByAdminRequest params){
        var result = userService.updateByAdmin(params);
        return ResultUtils.success(result);
    }

    @PostMapping("/add")
    public BaseResponse<Long> add(@RequestBody AddRequest params){
        var result = userService.add(params);
        return ResultUtils.success(result);
    }
}
